<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/27
 * Time: 18:18
 */
//增加数据
$name = $_POST["name"];
$age = $_POST["age"];
$sex = $_POST["sex"];
$no = $_POST["no"];
$tel = $_POST["tel"];

try
{
    $pdo = new PDO("mysql:host=127.0.0.1;dbname=test0925","root","");
    $pdo->exec("SET NAMES 'utf8'");
}
catch (Exception $e)
{
    var_dump($e);
    die("连接失败");
}

$insertSQL = "insert into zkw_user (name,no,tel,sex,age) 
VAlUES('$name','$no','$tel','$sex',$age);";

$res = $pdo -> exec($insertSQL);

if ($res > 0)
{
    echo "<meta http-equiv=\"refresh\" content=\"1; url=userTable.php\">";
    print('注册成功!!<br>1秒后自动跳转....');

}else{
    echo "注册失败";
    var_dump($pdo->errorInfo());
}





